using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using Skywave.Windows.Forms.RuntimeDesign;

namespace Skywave.Windows.Forms
{
    public partial class SimpleFormDesignerForm : Form
    {
        public SimpleFormDesignerForm()
        {
            InitializeComponent();
        }

        private Skywave.ComponentModel.ProfilesHolder mProfilesHolder;
        [Browsable(false)]
        public Skywave.ComponentModel.ProfilesHolder ProfilesHolder
        {
            get { return mProfilesHolder; }
            set
            {
                mProfilesHolder = value;
                profilesManager1.InitializeMe(mProfilesHolder);
            }
        }

        public FormDesigner FormDesigner
        {
            get { return formDesigner1; }
            set
            {
                formDesigner1.CopyFrom(value);
            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void profilesManager1_Serialize(object sender, ProfilesManagerProfileEventArgs e)
        {
            formDesigner1.SaveTo(e.Content);
        }

        IFormatter formatter = new BinaryFormatter();
        private void profilesManager1_Deserialize(object sender, ProfilesManagerProfileEventArgs e)
        {
            formDesigner1.LoadFrom(e.Content);
        }

        private void SimpleFormDesignerForm_Load(object sender, EventArgs e)
        {
            formDesigner1.InitializeMe();
        }
    }
}